/**
 * <p>功能:系统管理模块-权限管理-用户管理 <p>
 * @extends Wys.basic.BaseView
 * @author wys
 */
Ext.define('Jason.view.protal.module.systemManager.right.users.MainView', {
    extend: 'Ext.container.Container',
    xtype: 'systemManager_right_usersView',
    requires: [
        'Ext.panel.Panel',
        'Wys.form.field.SearchField',
        'Wys.toolbar.NoInputPaging',
        'Wys.form.field.UploadField',
        'Wys.form.field.VTypes',
        'Wys.utils.Config',
        'Wys.form.BaseWindow',
        'Wys.button.Refresh',
        'Ext.button.Button',
        'Wys.combobox.ComboTree',
        'Jason.store.protal.module.systemManager.right.organize.TreeStore',
        'Jason.store.protal.module.systemManager.right.users.UserSearchByRoleStore',
        'Jason.store.protal.module.systemManager.right.users.UsersStore',
        'Jason.view.protal.module.systemManager.right.users.ViewModel',
        'Jason.view.protal.module.systemManager.right.users.MainCtrl'
    ],
    controller: 'right_users_MainViewCtrl',
    viewModel: { type: 'users_MainViewModel' },
    layout: {
        type: 'hbox',
        align: 'stretch'
    },
    items: [
        {
            cls: 'faq-left-sidebar shadow-panel',
            ui: 'light',
            border: true,
            xtype: 'treepanel',
            title: '数据结构',
            ui: 'light',
            reserveScrollbar: true,
            useArrows: true,
            rootVisible: false,
            multiSelect: true,
            singleExpand: true,
            tools: [{
                type: 'expand',
                tooltip: I18N.expandText,
                handler: function (exp, e, header) {
                    header.up('treepanel').expandAll();
                }
            }, {
                type: 'collapse',
                tooltip: I18N.collapseText,
                handler: function (exp, e, header) {
                    header.up('treepanel').collapseAll();
                }
            }, {
                type: 'refresh',
                tooltip: '点击刷新数据结构',
                listeners: {
                    click: 'refreshLeftMenuTree'
                }
            }],
            bind: '{leftMenuTreeStore}',
            listeners: {
                itemclick: 'onTreeNodeClick'
            },
            dockedItems: [{
                xtype: 'toolbar-noinputpaging',
                bind: '{leftMenuTreeStore}',
                dock: 'bottom'
            }],
            iconCls: 'x-fa fa-sitemap',
            responsiveConfig: {
                'width < 1000': {
                    width: 0,
                    visible: false
                },
                'width >= 1000 && width < 1600': {
                    width: 250,
                    visible: true
                },
                'width >= 1600': {
                    width: 300,
                    visible: true
                }
            },
            plugins: [
                {
                    ptype: 'responsive'
                }
            ]
        },
        {
            xtype: 'baseView',
            ui: 'light',
            itemId: 'usersGrid',
            margin: '0 0 0 6',
            flex: 1,
            enabledMark: false,
            dockedItems: [{
                xtype: 'toolbar',
                dock: 'top',
                items: [{
                    xtype: 'button',
                    menu: [{
                        xtype: 'useFilter',
                        width: 400,
                        filterscheme: {
                            details: [{
                                cols: 1,
                                details: [{
                                    defaulttitle: "用户姓名",
                                    fieldname: "realname"
                                }, {
                                    defaulttitle: "登录账号",
                                    fieldname: "loginname"
                                }, {
                                    defaulttitle: "注册时间",
                                    isDateField: true,
                                    fieldname: "createtime"
                                }, {
                                    defaulttitle: "民族",
                                    labelWidth: 80,
                                    isDictionary: true,
                                    dictTypeName: "NATION",
                                    fieldname: "nation"
                                }, {
                                    defaulttitle: "用户状态",
                                    isDictionary: true,
                                    dictTypeName: "Duty",
                                    fieldname: "jobstate"
                                }]
                            }]
                        }
                    }],
                    iconCls: 'fa fa-filter'
                }, {
                    xtype: 'gridsearchfield', paramName: 'loginname'
                }, {
                    xtype: 'segmentedbutton',
                    items: [{
                        xtype: 'newbutton',
                        rightCode: 'USERMANAGER'
                    }, {
                        xtype: 'editbutton',
                        rightCode: 'USERMANAGER'
                    }, {
                        xtype: 'deletebutton',
                        rightCode: 'USERMANAGER'
                    }, {
                        xtype: 'button',
                        text: '禁用',
                        ui: 'soft-red',
                        handler: 'onChangeUserState',
                        iconCls: 'x-fa fa-close',
                        itemId: 'disabled'
                    }, {
                        xtype: 'button',
                        text: '启用',
                        ui: 'soft-green',
                        handler: 'onChangeUserState',
                        iconCls: 'x-fa fa-check',
                        itemId: 'enabled'
                    }, {
                        xtype: 'button',
                        text: '重置密码',
                        ui: 'soft-purple',
                        handler: 'onResetPwd',
                        iconCls: 'x-fa fa-recycle',
                        itemId: 'resetPwd'
                    }]
                }, '->', {
                    xtype: 'refresh', viewItemId: '#usersGrid',
                    rightCode: 'USERMANAGER'
                }, {
                    xtype: 'exportbutton', rightCode: 'USERMANAGER',
                    modularText: '用户管理'
                }]
            }, {
                xtype: 'pagingtoolbar',
                bind: '{userGridStore}',
                dock: 'bottom'
            }],
            bind: '{userGridStore}',
            selType: 'checkboxmodel',
            listeners: {
                itemdblclick: 'onEditButtonClick'
            },
            multiSelect: true,
            columns: [
                { xtype: 'rownumberer', text: '序号', align: 'center', width: 50 },
                {
                    text: '状态', align: 'center', dataIndex: 'jobstate', width: 70,
                    renderer: function (value, m, r) {
                        var v = r.data.jobstate;
                        return v === 1 ? '<div class="custom-tag custom-tag-success">正常</div>' : v === 2 ? '<div class="custom-tag custom-tag-warning">离职</div>' : v === 3 ?
                            '<div class="custom-tag custom-tag-danger">禁用</div>' : '<div class="custom-tag custom-tag-info">其他</div>';
                    }
                },
                {
                    text: '姓名', dataIndex: 'realname', minWidth: 100, flex: 2, renderer: function (v, mate) {
                        mate.style = "font-weight:bold;";
                        return v;
                    }
                },
                { text: '帐号', dataIndex: 'loginname', minWidth: 100, flex: .2 },
                { text: '性别', dataIndex: 'sexText', width: 47, menuDisabled: true/*,dicType:'Gender',xtype:'dictColumn'*/ },
                { text: '民族', dataIndex: 'nationText', width: 92, menuDisabled: true/*,dicType:'NATION',xtype:'dictColumn'*/ },
                //				{text : '证件号码',dataIndex:'idcard',minWidth:130,flex:.3,menuDisabled:true},
                { text: '联系电话', dataIndex: 'mobphone', minWidth: 110, flex: .35, menuDisabled: true },
                { text: '创建日期', dataIndex: 'createDate', width: 135, xtype: 'datecolumn', format: 'Y-m-d H:i' }
            ]
        }
    ]
});